/**
 * @description Model Manifest
 *
 * @author Xiongmao
 */

var db = require('../db');

module.exports = db.model('Repair', {
    tableName: 'repairs',
    hasTimestamps: true,
    creator() {
        return this.belongsTo('User', 'creator_id');
    },
    allocator() {
        return this.belongsTo('User', 'allocator_id');
    },
    checker() {
        return this.belongsTo('User', 'checker_id');
    },
    department() {
        return this.belongsTo('Department', 'department_id');
    },
    repairer() {
        return this.belongsTo('User', 'repairer_id');
    },
    goods() {
        return this.hasMany('RepairGood', 'repair_id');
    }
}, {
    PENDING: 0, // 待分配
    ALLOCATED: 1, // 已分配
    REPAIRED: 2, // 已维修
    CALLBACK: 4, // 已退回
    COMPLETED: 3 // 已完工
});
